package org.anti996.bankms.controller;

import org.anti996.bankms.util.IOUtil;
import org.anti996.bankms.util.MessageUtil;
import org.anti996.bankms.view.ViewBase;

public class ControllerBase {
    protected final ViewBase view_;
    private boolean refresh_ = true;

    public ControllerBase(ViewBase view) {
        view_ = view;
    }

    public void deal() {
        if (refresh_) {
            refresh();
            if (view_ != null) view_.show();
        }
        if (view_ != null) MessageUtil.info("请输入您的选择：");
        refresh_ = true;
    }

    public void noRefreshOnce() {
        refresh_ = false;
    }

    public void wrongInputAndRetry() {
        MessageUtil.error("输入有误，请重新输入！");
        noRefreshOnce();
    }

    public void refresh() {
        // TODO 刷新页面的功能
    }

    public void waitForKeyPress() {
        System.out.print("(^_^)按回车...");
        IOUtil.parseInput();
    }
}
